﻿/*
 * Сделано в SharpDevelop.
 * Пользователь: Кулик
 * Дата: 01.04.2011
 * Время: 17:02
 * 
 * Для изменения этого шаблона используйте Сервис | Настройка | Кодирование | Правка стандартных заголовков.
 */
using System;
using Video.Mov;
using Video;
using NLog;

namespace TestMOV
{
	class Program
	{
		public static void Main(string[] args)
		{
			//Console.WriteLine("Hello World!");
			Decoder decoder = new Decoder(@"c:\temp\sample.3gp");
			//decoder.ReadAtom();
			
			Encoder encoder = new Encoder(@"c:\temp\my.3gp");
			
			//FTYP
			Atom atom = new Atom();
			atom.Size = 24;
			atom.Type = "ftyp".ToCharArray();
			FtypAtom ftyp = new FtypAtom(atom);
			ftyp.MajorBrand = "3gp5".ToCharArray();
			ftyp.Ver = 256;
			ftyp.CompatibleBand1 = "3gp5".ToCharArray();
			ftyp.CompatibleBand2 = "3gp4".ToCharArray();			
			encoder.WriteAtom(ftyp);
			
			//MVHD
			atom.Size = 108;
			atom.Type = "mvhd".ToCharArray();
			MovieHeaderAtom mvhd = new MovieHeaderAtom(atom);
			mvhd.Version = 0;
			mvhd.Flags = new byte[3];
			mvhd.CreationTime = 3213365800;
			mvhd.ModificationTime = 3213365800;
			mvhd.TimeScale = 600;
			mvhd.Duration = 2960;
			mvhd.PreferredRate = 65536;
			mvhd.PreferredVolume = 256;
			mvhd.Reserved = new byte[10];
			mvhd.MatrixStructure =  new byte[36];
			mvhd.MatrixStructure[1] = 1;
			mvhd.MatrixStructure[17] = 1;
			mvhd.MatrixStructure[32] = 64;
			mvhd.PreviewTime = 0;
			mvhd.PreviewDuration = 0;
			mvhd.PosterTime = 0;
			mvhd.SelectionTime = 0;
			mvhd.SelectionDuration = 0;
			mvhd.CurrentTime =0;
			mvhd.NextTrackID = 1;
			
			//TKHD
			
			
			//TRAK
			Atom trak = new Atom();
			trak.Size = 0;
			trak.Type = "trak".ToCharArray();
			
			//MOOV
			atom.Size = 108;
			atom.Type = "moov".ToCharArray();
			atom.Child.Add(mvhd);
			atom.Child.Add(trak);
			
			encoder.WriteAtom(atom);
			
			
			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}
	}
}